poloyy-archive
首页 / Pytest / Pytest系列(12)- 测试结果生成HTML报告插件之pytest-html的详细使用

Pytest系列(12)- 测试结果生成HTML报告插件之pytest-html的详细使用

Pytest  ·  原文归档  ·  点击图片可放大

环境前提

Python3.6+

安装插件

pip3 install pytest-html -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com

快速入门

pytest --html=report.html

会在当前目录下创建一个report.html的测试报告

合并CSS

上面命令生成的报告,css是独立的,分享报告的时候样式会丢失,为了更好的分享发邮件展示报告,可以把css样式合并到html里

pytest --html=report.html --self-contained-html

注意事项

  • 在将文件或链接添加到独立报告时,插件会发出warnings;
  • 在html测试报告中可能无法按预期显示文件或链接
上一篇Pytest系列(11)- 失败重跑插件pytest-rerunfailures的详细使用 下一篇Pytest系列(13)- 重复执行用例插件之pytest-repeat的详细使用